package map;


import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;

public class MapDemo2 {
    public static void main(String[] args) {
        Map<String,Integer> map=new HashMap<>();
        map.put("语文",109);
        map.put("数学",131);
        map.put("英语",117);
        map.put("理综",222);
        map.put("总分",579);
        System.out.println(map);
        Set<String> set=map.keySet();
        for(String key:set){
            System.out.println("key:"+key);
        }
        Set<Map.Entry<String,Integer>> set1=map.entrySet();
        for(Map.Entry<String,Integer> e:set1){
            String key=e.getKey();
            Integer value=e.getValue();
            System.out.println(key+":"+value);
        }

        Collection<Integer> values=map.values();
        for(Integer value:values){
            System.out.println("value:"+value);
        }

        set1.forEach(s -> System.out.println(s));
        set1.forEach(new Consumer<Map.Entry<String, Integer>>() {
            @Override
            public void accept(Map.Entry<String, Integer> stringIntegerEntry) {
                System.out.println(stringIntegerEntry);
            }
        });

    }
}
